import { TimelineLite } from "../../greensock/TimelineLite";
import { TweenLite } from "../../greensock/TweenLite";
import { GAlertWin } from "./GAlertWin";
import { 5 } from "../../../0/5";
type int = number;
//class Alert
    
    export  class Alert
    {
        constructor(arg1: Object /* flash.display.DisplayObjectContainer */)
        {
            
            if (Alert._instance != null) 
            {
                throw new Error(" AlertManager 单例 ");
            }
            Alert.stage = arg1;
            return;
        }

        public static wiggle(arg1: Object /* flash.display.DisplayObject */): void
        {
            var obj: Object /* flash.display.DisplayObject */;
            var x: number;
            var y: number;
            var timeLite: TimelineLite;

            var loc1;
            timeLite = null;
            obj = arg1;
            x = obj.x;
            y = obj.y;
            timeLite = new TimelineLite();
            timeLite.append(new TweenLite(obj, 0.02, {"x": x - 7, "y": y}));
            timeLite.append(new TweenLite(obj, 0.02, {"x": x, "y": y + 5}));
            timeLite.append(new TweenLite(obj, 0.02, {"x": x + 7, "y": y}));
            timeLite.append(new TweenLite(obj, 0.02, {"x": x, "y": y - 5}));
            timeLite.append(new TweenLite(obj, 0.02, {"x": x - 7, "y": y}));
            timeLite.append(new TweenLite(obj, 0.02, {"x": x, "y": y + 5}));
            timeLite.append(new TweenLite(obj, 0.02, {"x": x + 7, "y": y}));
            timeLite.append(new TweenLite(obj, 0.02, {"x": x, "y": y - 5}));
            timeLite.append(new TweenLite(obj, 0.02, {"x": x - 7, "y": y}));
            timeLite.append(new TweenLite(obj, 0.02, {"x": x, "y": y + 5}));
            timeLite.append(new TweenLite(obj, 0.02, {"x": x + 7, "y": y}));
            timeLite.append(new TweenLite(obj, 0.02, {"x": x, "y": y - 5}));
            timeLite.append(new TweenLite(obj, 0.02, {"x": x, "y": y, "onComplete":(): void
            {
                timeLite.stop();
                timeLite.kill();
                timeLite = null;
                return;
            }}))
            timeLite.play();
            return;
        }

        public static flick(arg1: Object /* flash.display.DisplayObject */): void
        {
            var obj: Object /* flash.display.DisplayObject */;
            var x: number;
            var y: number;
            var timeLite: TimelineLite;

            var loc1;
            timeLite = null;
            obj = arg1;
            x = obj.x;
            y = obj.y;
            timeLite = new TimelineLite();
            timeLite.append(new TweenLite(obj, 0.05, {"glowFilter":{"color": 14540253, "alpha": 5, "blurX": 100, "blurY": 100, "inner": true}}));
            timeLite.append(new TweenLite(obj, 0.05, {"glowFilter":{"color": 14540253, "alpha": 1, "blurX": 1, "blurY": 1, "inner": true}}));
            timeLite.append(new TweenLite(obj, 0.05, {"glowFilter":{"color": 14540253, "alpha": 5, "blurX": 100, "blurY": 100, "inner": true}}));
            timeLite.append(new TweenLite(obj, 0.05, {"glowFilter":{"color": 14540253, "alpha": 1, "blurX": 1, "blurY": 1, "inner": true}}));
            timeLite.append(new TweenLite(obj, 0.05, {"glowFilter":{"color": 14540253, "alpha": 5, "blurX": 100, "blurY": 100, "inner": true}}));
            timeLite.append(new TweenLite(obj, 0.05, {"glowFilter":{"color": 14540253, "alpha": 1, "blurX": 1, "blurY": 1, "inner": true}, "onComplete":(): void
            {
                timeLite.stop();
                timeLite.kill();
                timeLite = null;
                return;
            }}))
            timeLite.play();
            return;
        }

        public static show(arg1: string="", arg2=null, arg3: uint=4, arg4: Object /* flash.display.Sprite */=null, arg5: Function=null, arg6: Class=null, arg7: uint=4): Object /* flash.display.Sprite */
        {
            var Alert.text: string="";
            var Alert.title=null;
            var flags: uint=4;
            var Alert.parent: Object /* flash.display.Sprite */=null;
            var Alert.closeHandler: Function=null;
            var Alert.iconClass: Class=null;
            var Alert.defaultButtonFlag: uint=4;
            var myAlert: Object /* flash.display.Sprite */;
            var container: Object /* flash.display.DisplayObjectContainer */;
            var containerWidth: number;
            var containerHeight: number;
            var clickHandler: Function;
            var removeHandler: Function;

            var loc1;
            myAlert = null;
            container = null;
            containerWidth = NaN;
            containerHeight = NaN;
            clickHandler = null;
            removeHandler = null;
            Alert.text = arg1;
            Alert.title = arg2;
            flags = arg3;
            Alert.parent = arg4;
            Alert.closeHandler = arg5;
            Alert.iconClass = arg6;
            Alert.defaultButtonFlag = arg7;
            clickHandler = (arg1: Object /* flash.events.MouseEvent */): void
            {
                var loc1=arg1.target as Object /* flash.display.DisplayObject */;
                var loc2=arg1.currentTarget as GAlertWin;
                if (!loc2.window.contains(loc1)) 
                {
                    if (loc2.promptBackground) 
                    {
                        Alert.flick(loc2.promptBackground);
                    }
                }
                return;
            }
            removeHandler = (arg1: Object /* flash.events.Event */): void
            {
                myAlert.removeEventListener(flash.events.Event.REMOVED_FROM_STAGE, removeHandler);
                myAlert.removeEventListener(flash.events.MouseEvent.CLICK, clickHandler);
                return;
            }
            Alert.text = Alert.text;
            Alert.title = Alert.title;
            Alert.buttonFlags = flags;
            if (Alert.parent) 
            {
                Alert.parent = Alert.parent;
            }
            Alert.closeHandler = Alert.closeHandler;
            if (Alert.iconClass) 
            {
                Alert.iconClass = Alert.iconClass;
            }
            Alert.defaultButtonFlag = Alert.defaultButtonFlag;
            if (!Alert.stage && !Alert.parent) 
            {
                throw new Error("AlertManager尚未初始化!必需指定Alert窗口显示的容器");
            }
            if (Alert.parent) 
            {
                containerWidth = Alert.parent.width;
                containerHeight = Alert.parent.height;
                container = Alert.parent;
            }
            else 
            {
                if (Alert.stage is flash.display.Stage) 
                {
                    containerWidth = Alert.stage.stageWidth;
                    containerHeight = Alert.stage.stageHeight;
                }
                else if (Alert.stage is flash.display.DisplayObjectContainer) 
                {
                    containerWidth = Alert.stage.stage.stageWidth;
                    containerHeight = Alert.stage.stage.stageHeight;
                }
                container = Alert.stage;
            }
            if (Alert.alertWinRenderer) 
            {
                myAlert = new Alert.alertWinRenderer(containerWidth, containerHeight);
            }
            else 
            {
                myAlert = new GAlertWin(Alert.stage.stageWidth, Alert.stage.stageHeight);
            }
            container.addChild(myAlert);
            if (typeof myAlert === "galertwin") 
            {
                myAlert.addEventListener(flash.events.MouseEvent.CLICK, clickHandler);
                myAlert.addEventListener(flash.events.Event.REMOVED_FROM_STAGE, removeHandler);
            }
            if (Alert.isWiggle) 
            {
                Alert.wiggle(myAlert);
            }
            Alert.resetToDefault();
            return myAlert;
        }

        public static init(arg1: Object /* flash.display.DisplayObjectContainer */): void
        {
            if (Alert._instance == null) 
            {
                Alert._instance = new Alert(arg1);
            }
            return;
        }

        public static set defaultAlertWinRenderer(arg1: Class)
        {
            Alert.alertWinRenderer = arg1;
            Alert._defaultAlertWinRenderer = arg1;
            return;
        }

        public static get defaultAlertWinRenderer(): Class
        {
            return Alert._defaultAlertWinRenderer;
        }

        
        {
            Alert.text = "";
            Alert.buttonFlags = 0;
            Alert.okLabel = "确定";
            Alert.calcelLabel = "取消";
            Alert.yesLabel = "是";
            Alert.noLabel = "否";
            Alert.checkBoxLabel = "今日不再提示！";
            Alert.okLabelDefault = "确定";
            Alert.calcelLabelDefault = "取消";
            Alert.yesLabelDefault = "是";
            Alert.noLabelDefault = "否";
            Alert.checkBoxLabelDefault = "今日不再提示！";
            Alert.defaultButtonFlag = 4;
            Alert.buttonWidth = 49;
            Alert.buttonHeight = 25;
            Alert.textColor = 16777215;
            Alert.titleColor = 16777215;
            Alert.buttonColor = 5143985;
            Alert.buttonTextColor = 16777215;
            Alert.backgroundColor = 5143985;
            Alert.backgroundAlpha = 0;
            Alert.mode = "simple";
            Alert.alertWinRenderer = null;
            Alert.timerOut = 0;
            Alert.timerNO = false;
            Alert.needCallCloseHandler = true;
            Alert._defaultAlertWinRenderer = null;
            Alert.stage = null;
        }

        public static resetToDefault(): void
        {
            Alert.okLabel = Alert.okLabelDefault;
            Alert.calcelLabel = Alert.calcelLabelDefault;
            Alert.yesLabel = Alert.yesLabelDefault;
            Alert.noLabel = Alert.noLabelDefault;
            Alert.text = "";
            Alert.title = null;
            Alert.buttonFlags = 0;
            Alert.parent = null;
            Alert.closeHandler = null;
            Alert.iconClass = null;
            Alert.defaultButtonFlag = 4;
            Alert.buttonWidth = 49;
            Alert.buttonHeight = 25;
            Alert.textColor = 16777215;
            Alert.titleColor = 16777215;
            Alert.buttonColor = 5143985;
            Alert.buttonTextColor = 16777215;
            Alert.backgroundColor = 5143985;
            Alert.backgroundAlpha = 0;
            Alert.titleTextFormat = null;
            Alert.messageTextFormat = null;
            Alert.alertWinRenderer = defaultAlertWinRenderer;
            Alert.mode = "simple";
            Alert.timerOut = 0;
            Alert.buttonStyleName = null;
            Alert.showCloseBtn = false;
            Alert.isWiggle = false;
            Alert.timerNO = false;
            Alert.needCallCloseHandler = true;
            Alert.extendObj = null;
            Alert.timerOutHandler = null;
            Alert.checkBoxLabel = Alert.checkBoxLabelDefault;
            return;
        }

        public static /* const */YES: int=1;

        public static /* const */NO: int=2;

        public static /* const */OK: int=4;

        public static /* const */CANCEL: int=8;

        public static /* const */CLOSE: int=16;

        public static /* const */Mode_Blur: string="blur";

        public static /* const */Mode_NoneNotModal: string="nonenotmodal";

        public static /* const */Mode_Simple: string="simple";

        public static /* const */Mode_None: string="none";

        public static /* var */text: string="";

        public static /* var */title;

        public static /* var */buttonFlags: uint=0;

        public static /* var */parent: Object /* flash.display.DisplayObjectContainer */;

        public static /* var */okLabel: string="确定";

        public static /* var */calcelLabel: string="取消";

        public static /* var */yesLabel: string="是";

        public static /* var */noLabel: string="否";

        public static /* var */checkBoxLabel: string="今日不再提示！";

        public static /* var */okLabelDefault: string="确定";

        public static /* var */calcelLabelDefault: string="取消";

        public static /* var */yesLabelDefault: string="是";

        public static /* var */isWiggle: Boolean;

        public static /* var */textColor: uint=16777215;

        public static /* var */titleColor: uint=16777215;

        public static /* var */buttonColor: uint=5143985;

        public static /* var */buttonTextColor: uint=16777215;

        public static /* var */backgroundColor: uint=5143985;

        public static /* var */backgroundAlpha: number=0;

        public static /* var */buttonStyleName: string;

        public static /* var */titleTextFormat: Object /* flash.text.TextFormat */;

        public static /* var */messageTextFormat: Object /* flash.text.TextFormat */;

        public static /* var */mode: string="simple";

        public static /* var */alertWinRenderer: Class=null;

        public static /* var */timerOut: int=0;

        public static /* var */buttonHeight: int=25;

        public static /* var */extendObj: Object;

        public static /* var */timerOutHandler: Function;

        public static /* var */needCallCloseHandler: Boolean=true;

        private static /* var */_defaultAlertWinRenderer: Class=null;

        private static /* var */stage=null;

        private static /* var */_instance: Alert;

        public static /* var */showCloseBtn: Boolean;

        public static /* var */buttonWidth: int=49;

        public static /* var */defaultButtonFlag: uint=4;

        public static /* var */iconClass: Class;

        public static /* var */closeHandler: Function;

        public static /* var */checkBoxLabelDefault: string="今日不再提示！";

        public static /* var */noLabelDefault: string="否";

        public static /* var */timerNO: Boolean=false;
    }
